package com.yjt.fresh.adpater;

import android.content.res.Resources;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.bean.BeanRechargeType;

import java.util.List;

/**
 * 充值类型
 * Created by mcc on 2018/6/10.
 */

public class AdpRvRechargeType extends BaseQuickAdapter<BeanRechargeType, BaseViewHolder> {

    private int mSelectPosition = -1;

    public int getSelectPosition() {
        return mSelectPosition;
    }

    public void setSelectPosition(int selectPosition) {
        mSelectPosition = selectPosition;
        notifyDataSetChanged();
    }

    public AdpRvRechargeType(int layoutResId, @Nullable List<BeanRechargeType> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanRechargeType item) {
        helper.setText(R.id.tvAppRecycleItemRechargeTypeMoney, item.getRECHARGE_MONEY());
        helper.setText(R.id.tvAppRecycleItemRechargeTypeGift, "充"+item.getRECHARGE_MONEY()+"送"+item.getSEND_MONEY());

        if (helper.getAdapterPosition() == mSelectPosition){
            Resources resources = mContext.getResources();
            helper.getConvertView().setBackground(resources.getDrawable(R.drawable.shape_43b624_5));
            ((TextView)helper.getView(R.id.tvAppRecycleItemRechargeTypeMoney)).setTextColor(resources.getColor(R.color.white));
            ((TextView)helper.getView(R.id.tvAppRecycleItemRechargeTypeGift)).setTextColor(resources.getColor(R.color.white));
        }else {
            Resources resources = mContext.getResources();
            helper.getConvertView().setBackground(resources.getDrawable(R.drawable.shape_ffffff_5));
            ((TextView)helper.getView(R.id.tvAppRecycleItemRechargeTypeMoney)).setTextColor(resources.getColor(R.color.color_333333));
            ((TextView)helper.getView(R.id.tvAppRecycleItemRechargeTypeGift)).setTextColor(resources.getColor(R.color.color_666666));
        }
    }
}
